#include <iostream>
using namespace std;
int main() {
	int M,X;
	cin>>M>>X;
	for(int x, y, z; cin >> x >> y >> z;) {
		int temp = 0;
		if(x > X) temp = X;
		else if(x < M) temp = M;
		else temp = x;
		cout<<temp<<" ";
		int page = 0;
		if(z % temp == 0) {
			page = z / temp;
		} else page = z / temp + 1;
		cout<<page<<" ";
		if(page == 0) {
			cout<<1<<" "<<0<<endl;
		}
		else if(y > page) {
			cout<<page<<" ";
			cout<<(page - 1) * temp<<endl;

		}
		else if(y <= 0) {
			cout<<1<<" ";
			cout<<0<<endl;
		} else {
			cout<<y<<" ";
			cout<<(y - 1) * temp<<endl;
		}
	}
	return 0;
}
